package com.fenghongzhang.a1807;

public class User {
    private String name;
    private String email;
    private String address;

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", email='" + email + '\'' +
                ", address='" + address + '\'' +
                '}';
    }

    public static class Builder{

        private String name;
        private String email;
        private String address;

        public Builder setName(String name){
            this.name = name;
            return this;
        }

        public Builder setAddress(String address){
            this.address = address;
            return this;
        }

        public User getUser(){
            User user = new User();
            user.name = name;
            user.address = address;
            return user;
        }
    }



    public static void main(String[] args) {
        Builder builder = new Builder();
        System.out.println("------------");
        Builder builder1 = builder.setName("xiaoming").setAddress("dizhi");

        User user = builder1.getUser();
        System.out.println(user);

    }
}
